﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.ServiceProcess;
using System.Text;

namespace DoubleClick.Windows
{
    partial class Service : ServiceBase
    {
        private Server server;

        public Service()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            if (Program.Default.StartupMode == StartupModeEnum.Service)
            {
                server = new Server(Program.Default);
                server.Start();
                return;
            }
            return;
        }

        protected override void OnStop()
        {
            server.Stop();
        }

        public void Installer()
        {
            ManagedInstallerClass.InstallHelper(new string[] 
            { 
                Assembly.GetExecutingAssembly().Location 
            });
        }

        public void Uninstaller()
        {
            ManagedInstallerClass.InstallHelper(new string[] 
            { 
                "/u",
                Assembly.GetExecutingAssembly().Location 
            });
        }
    }
}
